
/* global $ RemoveNewFreeOption AddNewFreeOption */

/**
 * 函数用于在小类tag点击的时候触发
 * @param {string} val 添加DIY表单的小类tag名称，exp：银行
 */
function AddNewFreeOption (val) {
  /** 获取对应小类id（数据库意义的id） */
  let uID = $(`input#${val}`).attr(`value`)
  /** 获取服务器上的表单数据 */
  let ajaxUrl = String($('#get_new_free_form').val())
  $.ajax(ajaxUrl, {
    method: 'POST',
    data: {m_group: uID},
    success: (data) => {
      // data.id 是数据库的表单id，至少目前看来是废的，已和后端确认
      // if (data.m_id) {
      if (data.formData.length > 0) {
        writeBackDIYForm(data)
      } else {
        addNewHiddenFree(11, uID, val)
      }
    },
    error: function (data) {
      console.clear()
      console.log(data)
    }
  })
}

/** 这个函数究竟要做什么：
 * 1：获取对话框的东西
 * 2：构建get链接
 * 3：ajax返回id后构建相应的选项和隐藏checkbox，并把val上去列表中
 * debugID是返回的
 * var newTagButton = `<input type="checkbox" name="${debugID}" id="check_${debugID}" value="${val}" checked>`
 * var button = `<span class="tag_content"><a inori-data='${val}' id="${debugID}">${val}</a></span>`
 * 4：ajax完成后删除自身
 */
function ajaxAddNewTag (_this, val, urlBase) {
  /** debug数据 */
  _this.setAttribute('onsubmit', 'return false')
  var debugID = 999
  var mainName = ''
  var altName = ''
  var summary = ''
  $.each( $(_this).children('input[type="text"]'), function (k, v) {
    var switchObj = {
      0: function () { mainName = $(this).val(); console.log(mainName) },
      1: function () { altName = $(this).val(); console.log(altName) },
      2: function () { summary = $(this).val(); console.log(summary) }
    }
    switchObj[k].call(v)
  })
  /** get 的方式放上去，返回一个ID */
  /** 补一个ajax后才给后端 */
  var selectedValue = $('#dalei').children('option:selected').val()
  var ajaxUrl = `${urlBase}?type=0&dalei=${selectedValue}&mainName=${mainName}&altName=${altName}&summary=${summary}`

  $.get(ajaxUrl, function (responseID) {
    /** 标签隐藏选框 */
    var newTagButton = `<input type="checkbox" name="check[]" id="${val}" value="${responseID}" checked>`
    $('#hidden_tag').append(newTagButton)
    /** 可见选框 */
    var button = `<span class="tag_content active"><a inori-data='${val}' right-click='true' id="_${val}">${val}</a></span>`
    $('#xiaolei_tag_list_button').prepend(button)
    /** 恢复标签栏可见 */
    $('.tag_search_list').css('visibility', 'visible')
    /* 还原网页标题 */
    let prevTitle = localStorage.getItem('prevTitle')
    if (prevTitle) $(document).attr('title', prevTitle)
    /** 清空对话栏 */
    $('#add_new_tag_content').empty()
    /** 自动补全列表中添加一个 */
    window.tagList.push(val)
    /** 解决焦点的问题 */
    $('.tag-editor.ui-sortable li:eq(-1)').remove()
    $('#xiaolei_tag_list').tagEditor('addTag', val, true)

    /** 在文件add_free_option.js定义 */
    // AddNewFreeOption(val)
    return false
  })
  return false

}
/** 清空父级元素 */
function deleteThis (_this) {
  $(_this.parentElement.parentElement.parentElement).prev().css('visibility','visible')
  $(_this.parentElement).empty()
}
/** 清空父级的父级元素 */
function deleteThisPar (_this) {
  $(_this.parentElement.parentElement).empty()
}
/** 清除利息颜色的父级元素 */
function deleteThisLX (_this) {
  let urlBase = $('#del_lixi').val()
  let LXId = $(_this).closest('div').prev('input').val()

  $.ajax({
    type: 'POST',
    url: urlBase,
    data: {id: LXId},
    async: false,
    cache: false
  }).done(function (data) {
    if (data.code === 200) {
      console.log(data)
      // 成功删除颜色
      let lixiColorEleID = $(_this).siblings('input').attr('inori-data')
      $(`#${lixiColorEleID}`).remove()
      $(_this.parentElement.parentElement).empty()
    } else {
      alart('失败')
    }
  }).fail(function (data) {
    alart('失败')
  })
}
/** 清空父级的父级的父级元素 */
function delete_this_par (_this) {
  console.log(_this)
  // $(_this.parentElement.parentElement).empty()
}

// 添加征信查询要求
var zhengxinChaxunCount = 0
function add_zhengxin_chaxun () {
  zhengxinChaxunCount++
  var zhengxin_box_string = `
<div class="zhengxin_sec_box">
  <div id = 'add_new_zhengxin_${zhengxinChaxunCount}' onclick="deleteThis(this)" class = 'delete_this_par'><img src="/Application/Admin/View/Public/images/set_chanpin_popup/u566.png" alt="u566" style="width:100%"></div>
  <div class="zhengxin_line">
    <span>查询次数： </span>
    <label style="width:30%;"><input checked type="radio" name="zhengxin_chaxun_${zhengxinChaxunCount}" id="zhengxin_chaxun_${zhengxinChaxunCount}_1" value="不看查询次数">不看查询次数</label>
    <label><input type="radio" name="zhengxin_chaxun_${zhengxinChaxunCount}" id="zhengxin_chaxun_${zhengxinChaxunCount}_2" value="看查询次数">看查询次数</label>
  </div>
  <div class="zhengxin_line">
    <span>查询计算标准： </span>
    <label><input checked type="checkbox" name="zhengxin_jisuan_biaozhun_${zhengxinChaxunCount}[]" id="zhengxin_jisuan_biaozhun_${zhengxinChaxunCount}_1">贷款申请</label>
    <label><input type="checkbox" name="zhengxin_jisuan_biaozhun_${zhengxinChaxunCount}[]" id="zhengxin_jisuan_biaozhun_${zhengxinChaxunCount}_2" >信用卡查询</label>
    <label><input type="checkbox" name="zhengxin_jisuan_biaozhun_${zhengxinChaxunCount}[]" id="zhengxin_jisuan_biaozhun_${zhengxinChaxunCount}_3" >个人查询</label>
    <label><input type="checkbox" name="zhengxin_jisuan_biaozhun_${zhengxinChaxunCount}[]" id="zhengxin_jisuan_biaozhun_${zhengxinChaxunCount}_4" >保前审批</label>
  </div>
  <div class="zhengxin_line">
    <span>查询计算跨度：</span>
    <!-- 多少月内 -->
    <label>
      <select name="zhengxin_qinei_${zhengxinChaxunCount}" id="zhengxin_qinei_${zhengxinChaxunCount}">
        <option value="1">1个月</option>
        <!-- 顺序 -->
        <option value="36">36个月</option>
      </select>
      内
    </label>
  </div>
  <div class="zhengxin_line">
    <span>不能超过： </span>
    <label>
        <select name="zhengxin_max_chaxun_${zhengxinChaxunCount}" id="zhengxin_max_chaxun_${zhengxinChaxunCount}">
          <option value="1">1次</option>
          <!-- 顺序 -->
          <option value="20">20次或以上</option>
        </select>
      </label>
  </div>
</div>`.trim()
  $('#zhengxin_chaxun_box').append(zhengxin_box_string)
}

$(document).ready(function () {
  // 大类修改 ajax
  var xiaoleiGet = $('#get_xiaolei_tag').val()
  $('#dalei').on('change', function () {
    var selectedValue = $(this).children('option:selected').val()

    // 修改隐藏color form区域
    $(`#dalei_color`).val(selectedValue)

    var textButton = ``
    var hiddenButton = ``
    $('#xiaolei_tag_list').next('.tag-editor').find('.tag-editor-delete').click();
    $('#xiaolei_tag_list').tagEditor('destroy')
    $('#xiaolei_tag_list').val()
    $('#xiaolei_tag_list_button').empty()
    $('#hidden_tag').empty()
    $.get(`${xiaoleiGet}?id=${selectedValue}`, function (data) {
      $.each(data, function (k, v) {
        console.log(k)
        console.log(v)
        textButton += `<span class="tag_content"><a inori-data='${v.name}' right-click='xiaolei' id="_${v.name}">${v.name}</a></span>`
        hiddenButton += `<input type="checkbox" name="check[]" value = '${v.id}' id="${v.name}">`
      })
      textButton += `<div id='add_new_tag_content'></div>`
      $('#xiaolei_tag_list_button').prepend(textButton)
      $('#hidden_tag').prepend(hiddenButton)
    })

    // $.get(`${xiaoleiGet}?value=${selectedValue}`, function (data) {
    //   console.log(data)
    //   // [["name"=>"kk", "value"=>"1",]["name"=>'kk',"uk"=>"2"]]

      // 搜索框逻辑
      $('#xiaolei_tag_list').tagEditor({
        initialTags: [],
        clickDelete: true,
        placeholder: '请点选或输入标签，点击空白处确认添加',
        autocomplete: {
          delay: 0,
          position: {collision: 'flip'},
          source: window.tagList
        },
        beforeTagSave: function (field, editor, tags, tag, val) { // 有就直接加，没有就添加
          // console.dir(field)
          // console.dir(editor)
          // console.dir(tags)// 添加前有的
          // console.log(tag)// 添加的
          // console.dir(val)// 添加的
          /** 验证是否存在，通过选取inori-data为val的元素的id来实现 */
          var isHas = $('#xiaolei_tag_list_button.tag_row [inori-data="' + val + '"]').attr('id')

          /** ajax地址本体，不含参数 */
          var urlBase = document.getElementById('add_xiaolei_tag').value

          if (!isHas) { // 不存在
            /** 可见对话框元素字符串，应附在$('#add_new_tag_content')内 */
            var addNewOption = `<form autocomplete="off" method="get" onsubmit='return ajaxAddNewTag(this, "${val}", "${urlBase}")' id='newTagOption'><input type="text" class='main_name' placeholder="正名" value='${val}'><input class='alt_name' type="text" placeholder="别名"> <input class= 'name_summary' type="text" placeholder="简短备注"><input type='submit' class='submit_ajax' value='确定'><span onclick='deleteThis(this)'>取消</span></form>`

            /** 附加对话框，将在确定按钮点击时消失 */
            $('#add_new_tag_content').append(addNewOption)
            $('.tag_search_list').css('visibility', 'hidden')
            localStorage.setItem('prevTitle', String($(document).attr('title')))
            $(document).attr('title', '请先完成当前操作')
            $('#add_new_tag_content .alt_name').focus()
            // 不添加
            return false

          } else { // 存在的
            $('#hidden_tag #' + val).prop('checked', true)
            // 检查有没有active
            if (!$(`#xiaolei_tag_list_button #_${val}`).closest('.tag_content ').hasClass('active')) {
              $(`#xiaolei_tag_list_button #_${val}`).closest('.tag_content ').addClass('active')
            }
            /** 在文件add_free_option.js定义 */
            AddNewFreeOption(val)
          }
        },
        beforeTagDelete: function (field, editor, tags, val) {
          // console.dir(field)
          // console.dir(editor)
          // console.dir(tags)// 去除前
          // console.dir(val)// 去除的那个
          $('#hidden_tag #' + val).prop('checked', false)
          if ($(`#xiaolei_tag_list_button #_${val}`).closest('.tag_content ').hasClass('active')) {
            $(`#xiaolei_tag_list_button #_${val}`).closest('.tag_content ').removeClass('active')
          }
          // $(`span.tag_content>a[inori-data=${val}]`).off('click', removeTagClick)
          /** 在文件add_free_option.js定义 */
          RemoveNewFreeOption(val)
        }
      })
    })

    // 点选框逻辑
      $('.multi_row_xiaolei_tag_search').on('click', function (e) {
        var target = e.target
        var data = target.getAttribute('inori-data')
        if (target.nodeName.toLowerCase() === 'a' && data !== undefined && !target.parentElement.classList.contains('active')) {
          $('#xiaolei_tag_list').tagEditor('addTag', data, true)
          target.parentElement.classList.add('active')
          target.addEventListener('click', function removeTagClick (e) {
            e.target.parentElement.classList.remove('active')
            $('#xiaolei_tag_list').tagEditor('removeTag', e.target.getAttribute('inori-data'), true)
            e.stopPropagation()
          }, {
            once: true
          })
          console.log(data)
        } else if (target.nodeName.toLowerCase() === 'a' && data !== undefined && target.parentElement.classList.contains('active')) {
          target.parentElement.classList.remove('active')
          $('#xiaolei_tag_list').tagEditor('removeTag', data, true)
          e.stopPropagation()
        }
      })
    // // })

  // 添加新利息
  if (window.lixi_count === undefined) {
    window.lixi_count = 0
  }
  $('#add_new_lixi').on('click', function () {
    $('#add_new_lixi').css('visibility', 'hidden')
    localStorage.setItem('prevTitle', String($(document).attr('title')))
    $(document).attr('title', '请先完成当前操作')
    var addNewListUrl = String($('#add_lixi').val())
    // <input type="hidden" name="商品id" class='php_g_id' value='{$vo.g_id}' form='not_submit'>
    let gIDArray = location.href.match(/\/id\/(\d+)\//)
    let gID = ''
    if (gIDArray === null || gIDArray === undefined) {
      throw new Error('页面地址错误')
    } else {
      gID = gIDArray[1]
    }

    // ajax begin
    $.post(`${addNewListUrl}`, {g_id: gID}, function (data) {
      $('#add_new_lixi').css('visibility', 'visible')
      /* 还原网页标题 */
      let prevTitle = localStorage.getItem('prevTitle')
      if (prevTitle) $(document).attr('title', prevTitle)
      if (data.code !== 1 && data.code !== 2) {
        throw new Error(`新建利息错误：返回数据code = ${data.code},message = ${data.message}`)
      }
      var lixiId = window.lixi_count
      var sample = `
        <div class="lixi_fenbu_main" id='lixi_fenbu_main_${lixiId}'>
          <input type="text" name="sanwei[lixi${window.lixi_count}][lixi_min]" placeholder="最低利息" class = 'min_lixi'>
          <input type="text" name="sanwei[lixi${window.lixi_count}][lixi_max]" placeholder="最高利息">
          <input type="text" name="sanwei[lixi${window.lixi_count}][edu_min]" placeholder="最低额度">
          <input type="text" name="sanwei[lixi${window.lixi_count}][edu_max]" placeholder="最高额度">
          <select name="sanwei[lixi${window.lixi_count}][huankuan]" class='huankuan_fangshi'>
            <option value="0" selected>还款方式</option>
            <option value="等额本息">等额本息</option>
            <option value="等额本金">等额本金</option>
            <option value="等本等息">等本等息</option>
            <option value="先息后本">先息后本</option>
          </select>
          <input type="num" name="sanwei[lixi${window.lixi_count}][fenqi_max]" placeholder="最长分期 1~360" required class='max_time'>
          <input type="text" name="sanwei[lixi${window.lixi_count}][fangkuan_shouxufei]" placeholder="放款手续费">
          <input type="text" name="sanwei[lixi${window.lixi_count}][daishou]" placeholder="代收">
          <input type="text" name="sanwei[lixi${window.lixi_count}][fandian]" placeholder="返点">
          <input type="text" name="sanwei[lixi${window.lixi_count}][fangkuan_time]" placeholder="放款时间" value='' required>
          <textarea name="sanwei[lixi${window.lixi_count}][du_zhuxi]" id="edu_zhuhxi" placeholder="利息额度备注" style='width: 100%;'></textarea>
          <input type="hidden" name="sanwei[lixi${window.lixi_count}][id]" value="${data.data}">
          <div class='lixi_sample_value' id='${lixiId}'><input form='hidden_color_placeholder' inori-data='color_lixi${lixiId}' id="color${lixiId}" type="text" name="color1" value="#000" />每10万月供:￥<span class="lixi_recal"></span>(36期)<span class='shouldMind' style='display:none;'>36期后还本</span><span id = 'remove_this_lixi' onclick='deleteThisLX(this)'><img src="/Application/Admin/View/Public/images/set_chanpin_popup/u566.png" alt="u566" style="width:100%"></span></div>
        </div>
        <script>
          $('#lixi_fenbu_main_${lixiId}').find('.huankuan_fangshi').on({change: recalLX}, {})
          $('#lixi_fenbu_main_${lixiId}').find('.min_lixi').on({change: recalLX}, {})
          $('#lixi_fenbu_main_${lixiId}').find('.max_time').on({change: recalLX}, {})
        </script>`.trim()
      let colorForm = `
      <form autocomplete="off" id="color_lixi${lixiId}">
        <input value='#00000' type="text" name="sanwei[lixi][min_lx]" id="sanwei[lixi${lixiId}][lixi_min]">
        <input value='#00000' type="text" name="sanwei[lixi][max_lx]" id="sanwei[lixi${lixiId}][lixi_max]">
        <input value='#00000' type="text" name="sanwei[lixi][min_ed]" id="sanwei[lixi${lixiId}][edu_min]">
        <input value='#00000' type="text" name="sanwei[lixi][max_ed]" id="sanwei[lixi${lixiId}][edu_max]">
        <input value='#00000' type="text" name="sanwei[lixi][repayments]" id="sanwei[lixi${lixiId}][huankuan]">
        <input value='#00000' type="text" name="sanwei[lixi][installment_fq]" id="sanwei[lixi${lixiId}][fenqi_max]">
        <input value='#00000' type="text" name="sanwei[lixi][handling]" id="sanwei[lixi${lixiId}][fangkuan_shouxufei]">
        <input value='#00000' type="text" name="sanwei[lixi][collection]" id="sanwei[lixi${lixiId}][daishou]">
        <input value='#00000' type="text" name="sanwei[lixi][return]" id="sanwei[lixi${lixiId}][fandian]">
        <input value='#00000' type="text" name="sanwei[lixi][fangkuan_time]" id="sanwei[lixi${lixiId}][fangkuan_time]">
        <input value='#00000' type="text" name="sanwei[lixi][lx_remark]" id="sanwei[lixi${lixiId}][du_zhuxi]">
      </form>
      `.trim()
      $('.lixi_fenbu').append(sample)
      $('#color_form_inside').append(colorForm)
      // 计数器自增，必须是填完才增
      window.lixi_count++
      $(`#color${lixiId}`).colorPicker(
        {
          onColorChange: function (id, newValue) {
            let targetID = $(this).prev('input').attr('inori-data')
            let targetEle = $(`#${targetID} input`)
            for (let ele of targetEle) {
              $(ele).val(newValue)
            }
            console.log(`ID: ${id} has been changed to ${newValue}`)
          }
        }
      )
    })
    // end ↑ ajax
  })

  // 添加关联
  $('#add_simple_frame').on('click', function () {
    var liTemp = document.getElementById('chanpin_simple_content').cloneNode(true)
    window.inori = liTemp
    liTemp.id = ''
    liTemp.getElementsByTagName('input')[1].value = ''
    liTemp.getElementsByTagName('input')[0].value = ''
    $('.chanpin_simple').append(liTemp)
  })
  // 标签删除
  $('.tag_row').on({contextmenu: rightClickMenu}, {})
  // 给input标签添加title，如果有title就不添加
  $.each($('input, textarea'), function (index, item) {
    const target = $(item)
    if (! !!target.attr('title')) target.attr('title', target.attr('placeholder'))
  })
})

// 利息计算
function lixi_calc () {
  $('.lixi_fenbu_main').each((index, item) => {
    $(item).find('.huankuan_fangshi').on({change: recalLX}, {})
    $(item).find('.min_lixi').on({change: recalLX}, {})
    $(item).find('.max_time').on({change: recalLX}, {})
  })
}
// 利息计算事件函数
function recalLX (evt) {
  // （100000(10万)/最长期数）+（100000（10万）X 最低利息X0.01）
  // 利息是 先息后本 则计算公式为（100000（10万）X 最低利息X0.01
  const parentEle = $(evt.target).closest('.lixi_fenbu_main')
  const minLixi = Number(parentEle.find('.min_lixi').val().replace(/[^\d.]/g, ''))
  const payType = String(parentEle.find('.huankuan_fangshi').val())
  const maxTime = Number(parentEle.find('.max_time').val().replace(/\D/g, '')) > 360 || Number(parentEle.find('.max_time').val().replace(/\D/g, '')) === 0 ? 36 : Number(parentEle.find('.max_time').val().replace(/\D/g, ''))
  const lixiRecal = parentEle.find('.lixi_recal')
  let lixiValue = 0
  // 处理数字并回填
  parentEle.find('.min_lixi').val(minLixi)
  parentEle.find('.max_time').val(maxTime)
  if (payType === '先息后本') {
    lixiValue = 1e5 * minLixi * 0.01
    parentEle.find('.shouldMind').css('display', 'unset')
  } else if (payType === '等额本息' || payType === '等额本金' || payType === '等本等息') {
    lixiValue = 1e5 / maxTime + 1e5 * minLixi * 0.01
    parentEle.find('.shouldMind').css('display', 'none')
  }
  lixiRecal.text('0')
  if (lixiValue < 1e5 && lixiValue > 0) lixiRecal.text(`${lixiValue.toFixed(3)} `)
  else lixiRecal.text('--- ')
}

// 右击删除标签
function rightClickMenu (evt) {
  // 限定在有right-click元素，防止错误响应
  if (!$(evt.target).attr('right-click') || ($(evt.target).attr('right-click') !== 'true' && $(evt.target).attr('right-click') !== 'xiaolei')) {
    return
  }
  evt.preventDefault()
  // 弹窗确认
  const shouldDelete = confirm('确定删除这个标签？')
  if (shouldDelete) {
    // 如果标签已经被激活
    if ($(evt.target).closest('.tag_content').hasClass('active') || `${$(evt.target).closest('[class^="multi_row"]').find('textarea').val()}`.match($(evt.target).text())) {
      alert('删除失败！标签正在被产品引用，请先保存相关产品后重试')
      console.log('本页产品就使用了这个标签！怎么删')
      return
    }
    const ajaxUrl = `${$('#ajax_del_biaoqian').val()}`
    let ajaxData = {
      biaoqian_id: `${$(evt.target).attr('id')}`.replace(/_/, ''), // 标签id
      biaoqian_type: `${$(evt.target).closest('.tag_row').attr('tag-type')}` // 标签类型
    }
    if ($(evt.target).attr('right-click') === 'xiaolei') {
      const tagID = $(evt.target).attr('inori-data')
      ajaxData.biaoqian_id = `${ $(`#hidden_tag #${tagID}`).attr('value')}`
    }
    if (!ajaxUrl || !ajaxData.biaoqian_id || !ajaxData.biaoqian_type || ajaxData.biaoqian_id === 'undefined' || ajaxData.biaoqian_type === 'undefined') {
      alert('删除标签需要的数据不完整！')
      console.log('删除标签需要的数据不完整:')
      console.dir([
        ajaxUrl,
        ajaxData.biaoqian_id,
        ajaxData.biaoqian_type,
      ])
      return
    }
    $.ajax(ajaxUrl, {
      type: 'post',
      data: ajaxData,
      beforeSend: () => {
        alert('正在删除，请稍侯')
      }
    }).fail((err) => {
      console.log(err)
      alert('删除失败')
    }).done((res) => {
      if(!res.code || (`${res.code}` !== '2' )) {
        // 不正常
        if (!res.code) {
          alert('服务器返回未知内容！查看控制台获取更多信息')
          console.log(`删除标签时，服务器返回`)
          console.log(res)
        } else if (`${res.code}` === '1' ) {
          if (res.data && res.data.length > 0) {
            alert(`删除失败！标签正在被产品引用( ${res.data[0].litter_name} 等)，请先保存相关产品后重试`)
          } else {
            alert('删除失败！标签正在被产品引用，请先保存相关产品后重试')
          }
          console.log(`删除标签时，服务器返回`)
          console.log(res)
        } else if (`${res.code}` === '3' ) {
          alert('删除失败！请重试')
          console.log(`删除标签时，服务器返回`)
          console.log(res)
        } else if (`${res.code}` === '4' ) {
          alert('删除失败！标签数据异常')
          console.log(`删除标签时，服务器返回`)
          console.log(res)
        }
      } else if (res.code && `${res.code}` === '2' ) {
        // 正常
        layer.msg('删除成功');
        // 移除小类标签本体
        if ($(evt.target).attr('right-click') === 'xiaolei') {
          const tagID = $(evt.target).attr('inori-data')
          $(evt.target).closest('span.tag_content').remove()
          $(`#hidden_tag #${tagID}`).remove()
        } else {
          // 移除标签本体
          const tagID = $(evt.target).attr('id')
          const tagContnt = $(evt.target).text()
          // value = '{$vo.id}' id="{$vo.name}"
          debugger
          $(evt.target).closest('span.tag_content').remove()
          $(`#${tagContnt}[value='${tagID}']`).remove()
        }
      }
    })
  } else {
    return
  }
}